package com.nulldev.util.scripting.cup.vee.registers;

import java.util.concurrent.atomic.AtomicReference;

import com.nulldev.util.scripting.cup.vee.CUPRegister;

public strictfp class FloatSFPCUPRegister extends CUPRegister<Float> {

	/* Only works on VEE running Java 16 or older */

	private final int registerID;

	public FloatSFPCUPRegister(final int registerID) {
		this.registerID = registerID;
	}

	private final AtomicReference<Float> value = new AtomicReference<Float>(0f);

	@Override
	public CUPRegisterType getRegisterType() {
		return CUPRegisterType.FLOAT_SFP;
	}

	@Override
	public void reset() {
		this.value.set(0f);
	}

	@Override
	public Float get() {
		return this.value.get();
	}

	@Override
	public void set(Float value) {
		this.value.set(value);
	}

	@Override
	public boolean valuePresent() {
		return this.value.get() != null;
	}

	@Override
	public int getRegisterID() {
		return this.registerID;
	}

}
